package com.yourenbang.lingyun.transaction.web.controller.ticket;

import com.yourenbang.lingyun.core.message.Request;
import com.yourenbang.lingyun.core.message.Result;
import com.yourenbang.lingyun.core.support.PageFrom;
import com.yourenbang.lingyun.core.util.KLog;
import com.yourenbang.lingyun.transaction.web.domain.dto.fund.AllyTicketDTO;
import com.yourenbang.lingyun.transaction.web.domain.dto.fund.DetailTicketDTO;
import com.yourenbang.lingyun.transaction.web.service.ticket.TicketAccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/transaction/ticket")
public class TicketAccountController {

    @Autowired
    private TicketAccountService ticketAccountService;

    /**
     * 银小云兑换券账户查询
     */
    @PostMapping(value = "/account")
    public Result billFoundYxy(@RequestBody Request<AllyTicketDTO> dto) {
        KLog.info("[银小云兑换券账户查询入参]:{}", dto);
        return ticketAccountService.allyTicketYxy(dto.getData());
    }

    /**
     * 银小云兑换券账单明细
     */
    @PostMapping(value = "/journal")
    public Result detailFoundYxy(@RequestBody Request<DetailTicketDTO> dto) {
        KLog.info("[银小云兑换券账单明细入参]:{}", dto);
        PageFrom.startPage(dto.getData().getPageNum(),dto.getData().getPageSize());
        Result result = ticketAccountService.detailTicketYxy(dto.getData());
        return result;
    }

    /**
     * 考拉快收兑换券账户查询
     * @see <a href="https://huoyan.kaolakuaishou.cn/project/97/interface/api/13440">火眼接口连接</a>
     */
    @PostMapping(value = "/account/klks")
    public Result billFoundKlks(@RequestBody Request<AllyTicketDTO> dto) {

        KLog.info("[考拉快收兑换券账户查询入参]:{}", dto);
        return ticketAccountService.allyTicketKlks(dto.getData());
    }

    /**
     * 考拉快收兑换券账单明细
     * @see <a href="https://huoyan.kaolakuaishou.cn/project/97/interface/api/13443">火眼接口连接</a>
     */
    @PostMapping(value = "/journal/klks")
    public Result detailFoundKlks(@RequestBody Request<DetailTicketDTO> dto) {

        KLog.info("[考拉快收兑换券账单明细入参]:{}", dto);
        PageFrom.startPage(dto.getData().getPageNum(),dto.getData().getPageSize());
        return ticketAccountService.detailTicketKlks(dto.getData());
    }
}
